﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using AutoPoco;
using AutoPoco.DataSources;
using AutoPoco.Engine;
using InvoiceProject.Controllers;
using InvoiceProject.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using InvoiceProject.Enums;
using Moq;
using NUnit.Framework;
using ExpectedException = Microsoft.VisualStudio.TestTools.UnitTesting.ExpectedExceptionAttribute;


namespace InvoiceProject.Tests.QuoteUnitTests
{


    [TestClass()]
    public class WhenCreatingOrUpdatingQuote
    {


        [TestMethod()]
        [Microsoft.VisualStudio.TestTools.UnitTesting.ExpectedException(typeof(ValidationException))]
        public void ShouldFailWhenQuoteDateIsGreaterThanQuoteExpiry()
        {
            var target = ModelGenerator.GetQuote();

            target.QuoteDate = DateTime.Now.AddDays(32);
            target.ExpiryDate = DateTime.Now;

            var validationContext = new ValidationContext(target, null, null);
            Validator.ValidateObject(target, validationContext, true);
        }


        [TestMethod()]
        public void ShouldPassWhenQuoteDateIsLessThanOrEqualToQuoteExpiry()
        {
            var target = ModelGenerator.GetQuote();

            target.QuoteDate = DateTime.Now;
            target.ExpiryDate = DateTime.Now.AddDays(32);
            target.InvoiceItems = new List<InvoiceItem>();
            var validationContext = new ValidationContext(target, null, null);
            Validator.ValidateObject(target, validationContext, true);
        }

       


    }





}



